import {createApp} from 'vue'
import lazyPlugin from 'vue3-lazy'

import App from './App'
import router from './router'
import store from './store'
import vant from './plugins/vant'
import globalComp from './plugins/component'
import filters from './filter/prefix'
import {getToken} from './utils/local'
import {getImageUrl} from './utils/utils'

import useCartStore from './store/shopcart'
import useUserStore from './store/user'

import './router/permission'

const app = createApp(App)

app.use(router)
app.use(store)
app.use(vant)
app.use(globalComp)
app.use(filters)
app.use(lazyPlugin, {loading: getImageUrl('loading')})
app.mount('#app')

if (getToken()) {
  useCartStore().updateCart()
  useUserStore().getUserInfo()
}

